﻿#ifndef STABILITY_ANALYSIS_H
#define STABILITY_ANALYSIS_H

#ifdef STABILITY_ANALYSIS_DLL_EXPORT
#define STABILITY_ANALYSIS_API __declspec(dllexport)
#else
#define STABILITY_ANALYSIS_API __declspec(dllimport)
#endif

#include <string>
#include <vector>
#include <map>
#include "BPAFilesIO.h"
#include "swi_typical_parameter.h"

struct SwiBatchParameter
{
    int ACFaultType;// 交流故障类型
    int DCFaultType;//直流故障类型
    double ACFaultBegin;//交流故障开始时间
    double ACFaultEnd;//交流故障结束时间
    double ACFrontCut;//交流前侧跳开时间
    double ACBackCut;//交流后侧跳开时间
    double DCFaultBegin;// 直流故障开始
    double DCCut;//直流切除时刻
    double VolMin;//电压下限
    double VolMax;//电压上限

    std::vector<std::string> ZoneName;//分区选择

    SwiBatchParameter()
    {
        ACFaultType = 31;
        DCFaultType = 11;
        ACFaultBegin = 0;
        ACFaultEnd = 0;
        ACFrontCut = 0;
        ACBackCut = 0;
        DCFaultBegin = 0;
        DCCut = 0;
        VolMin = 0;
        VolMax = 0;

        ZoneName.clear();
    }
};

#ifdef __cplusplus
extern "C"{
#endif
    // TODO: 稳定拼接

    // 典型稳定参数
    STABILITY_ANALYSIS_API std::vector<Swi::TypicalGenerator> ReadTypicalSwi(std::string filename);

    // 典型发电机参数替换
    STABILITY_ANALYSIS_API int TypicalGeneratorReplace(Swi::SwiFile swi_file, Swi::TypicalGenerator typical_generator, std::string replace_generator_name);

    // swi参数校验：容量不一致检测、缺失项检测
    STABILITY_ANALYSIS_API int SwiParameterCheck(Swi::SwiFile swi_file, Dat::DatFile dat_file);

    // swi批量计算
    STABILITY_ANALYSIS_API int SwiBatchCalculate(std::string swi_filename, const SwiBatchParameter& batch_parameter);

    // out批量解析
    STABILITY_ANALYSIS_API int OutBatchAnalysis();
#ifdef __cplusplus
}
#endif

#endif